﻿using System;
using System.Data;
using System.Web.UI.WebControls;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.Security;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Modules.POLL.Components;
using ASPNETVN.PORTAL.Components.Share;


namespace ASPNETVN.PORTAL.Modules.POLL.Controls
{
    public partial class Management : AddEditItemControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!PortalSecurity.HasManageAuthorization(this.ModuleID))
            {
                PortalSecurity.AccessDenied();
            }
            if (!IsPostBack)
            {
                LoadData();
            }
        }
        public void LoadData()
        {
            DataTable dt = Components.Question.Select_QuestionBy_ModuleID(this.ModuleID).Tables[0];
            gvQuestion.DataSource = dt;
            gvQuestion.DataBind();
            
        }

        protected void gvQuestion_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Components.Question.DeleleAnswerQuestion(Convert.ToInt32(gvQuestion.DataKeys[e.RowIndex].Value));
            LoadData();
        }

        protected void gvQuestion_PageIndexChanged(object sender, EventArgs e)
        {
            gvQuestion.SelectedIndex = -1;
        }

        protected void gvQuestion_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvQuestion.PageIndex = e.NewPageIndex;
            LoadData();
        }
    }
}